 // 引入nodejs-websocket
 const ws = require('nodejs-websocket');
 // 定义监听的host地址跟port端口
 const HOST = '127.0.0.1'
 const PORT = 3001;
 // 创建ws服务
 const service = ws.createServer((conn) => {
     conn.on('text', (message) => {
         // 当收到消息的时候就开始定时推送
         console.log('message', message);
         let a = 0
         setInterval(() => {
             // 随机推送message里的内容
             //  conn.sendText(`Now is ${new Date().getTime()}`);
             conn.sendText(`${a++}`);
         }, 1 * 5000);
     });
 }).listen(PORT, HOST, () => {
     console.log('service---success');
 });